package org.server.service;

import com.iohao.game.action.skeleton.core.flow.FlowContext;
import com.iohao.game.bolt.broker.client.kit.ExternalCommunicationKit;
import com.iohao.game.bolt.broker.client.kit.UserIdSettingKit;
import org.server.dao.UserDao;
import org.server.domain.Login.LoginVerify;
import org.server.domain.Login.MyAttachment;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginService {
    private UserDao userDao;
    public MyAttachment check(FlowContext flowContext,LoginVerify loginVerify) {
        MyAttachment myAttachment = userDao.attainUserInfo(loginVerify);
        if(myAttachment != null) {
            UserIdSettingKit.settingUserId(flowContext, myAttachment.userId);
            ExternalCommunicationKit.setAttachment(myAttachment);
            return myAttachment;
        }
        return null;
    }

    public MyAttachment getMyAttachment(Long userId) {
        return userDao.attainUserInfoByUserId(userId);
    }
    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
}
